package org.tru42.signal.processors.math;

import org.tru42.signal.lang.SObject;
import org.tru42.signal.lang.annotation.Signal;
import org.tru42.signal.lang.annotation.Sink;

public class MultiplyAdd extends SObject {
	
	private Number factor;
	
	private Number summand;
	
	@Signal
	public void result(long timestamp, Double value) {
		trigger("result", timestamp, value);
	}
	
	@Sink
	public void input(long timestamp, Number value) {
		result(timestamp, value.doubleValue() * factor.doubleValue() + summand.doubleValue());
	}
	
	@Sink
	public void factor(long timestamp, Number value) {
		this.factor = value;
	}

	@Sink
	public void summand(long timestamp, Number value) {
		this.summand = value;
	}

}
